package com.lyq.mr.speak;

import com.lyq.mr.wc.WordcountMapper;
import com.lyq.mr.wc.WordcountReducer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class SpeakDriver {

    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {

        Configuration conf =new Configuration();

        Job job = Job.getInstance(conf,"Speak");
        args = new String[] { "D:\\MR\\data\\mr-writable案例\\speak.data", "D:\\MR\\out\\speak3" };


        job.setJarByClass(SpeakDriver.class);

        job.setMapperClass(SpeakMapper.class);
        job.setReducerClass(SpeakReducer.class);

        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(SpeakBean.class);

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(SpeakBean.class);

        //读取的数据路径
        FileInputFormat.setInputPaths(job, new Path(args[0]));
        FileOutputFormat.setOutputPath(job, new Path(args[1]));

        boolean flag = job.waitForCompletion(true);
        System.exit(flag?0:1);

    }


}
